package com.analysis;

import com.commonfunction.CommFunction;
import com.databasefunction.AllDBFunction;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class SubmitAnalysisReportAction extends ActionSupport{
	private String barcode;
	
	private String pono,brockername,commisionAgent,datebusiness,partyname,vehicle,address,noofbag,city,weight;
		private String comodity,sandActual,sandDiff,pricesand,moistureActual,moistureDiff,priceSubMoisture,rate,damageActual,damageDiff,pricesubdamage;
	private String gross,costunload,lessRebet,discount,addDalali,totalR,totalRebet,advance;
	
	public String getAdvance() {
		return advance;
	}
	public void setAdvance(String advance) {
		this.advance = advance;
	}
	public String getCommisionAgent() {
		return commisionAgent;
	}
	public void setCommisionAgent(String commisionAgent) {
		this.commisionAgent = commisionAgent;
	}
	public String getDatebusiness() {
		return datebusiness;
	}
	public void setDatebusiness(String datebusiness) {
		this.datebusiness = datebusiness;
	}
	public String getWeight() {
		return weight;
	}
	public void setWeight(String weight) {
		this.weight = weight;
	}
	public String getBarcode() {
		return barcode;
	}
	public void setBarcode(String barcode) {
		this.barcode = barcode;
	}
	public String getPono() {
		return pono;
	}
	public void setPono(String pono) {
		this.pono = pono;
	}
	public String getBrockername() {
		return brockername;
	}
	public void setBrockername(String brockername) {
		this.brockername = brockername;
	}
	public String getPartyname() {
		return partyname;
	}
	public void setPartyname(String partyname) {
		this.partyname = partyname;
	}
	public String getVehicle() {
		return vehicle;
	}
	public void setVehicle(String vehicle) {
		this.vehicle = vehicle;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getNoofbag() {
		return noofbag;
	}
	public void setNoofbag(String noofbag) {
		this.noofbag = noofbag;
	}
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public String getComodity() {
		return comodity;
	}
	public void setComodity(String comodity) {
		this.comodity = comodity;
	}
	public String getSandActual() {
		return sandActual;
	}
	public void setSandActual(String sandActual) {
		this.sandActual = sandActual;
	}
	public String getSandDiff() {
		return sandDiff;
	}
	public void setSandDiff(String sandDiff) {
		this.sandDiff = sandDiff;
	}
	public String getPricesand() {
		return pricesand;
	}
	public void setPricesand(String pricesand) {
		this.pricesand = pricesand;
	}
	public String getMoistureActual() {
		return moistureActual;
	}
	public void setMoistureActual(String moistureActual) {
		this.moistureActual = moistureActual;
	}
	public String getMoistureDiff() {
		return moistureDiff;
	}
	public void setMoistureDiff(String moistureDiff) {
		this.moistureDiff = moistureDiff;
	}
	public String getPriceSubMoisture() {
		return priceSubMoisture;
	}
	public void setPriceSubMoisture(String priceSubMoisture) {
		this.priceSubMoisture = priceSubMoisture;
	}
	public String getRate() {
		return rate;
	}
	public void setRate(String rate) {
		this.rate = rate;
	}
	public String getDamageActual() {
		return damageActual;
	}
	public void setDamageActual(String damageActual) {
		this.damageActual = damageActual;
	}
	public String getDamageDiff() {
		return damageDiff;
	}
	public void setDamageDiff(String damageDiff) {
		this.damageDiff = damageDiff;
	}
	public String getPricesubdamage() {
		return pricesubdamage;
	}
	public void setPricesubdamage(String pricesubdamage) {
		this.pricesubdamage = pricesubdamage;
	}
	public String getGross() {
		return gross;
	}
	public void setGross(String gross) {
		this.gross = gross;
	}
	public String getCostunload() {
		return costunload;
	}
	public void setCostunload(String costunload) {
		this.costunload = costunload;
	}
	public String getLessRebet() {
		return lessRebet;
	}
	public void setLessRebet(String lessRebet) {
		this.lessRebet = lessRebet;
	}
	public String getDiscount() {
		return discount;
	}
	public void setDiscount(String discount) {
		this.discount = discount;
	}
	public String getAddDalali() {
		return addDalali;
	}
	public void setAddDalali(String addDalali) {
		this.addDalali = addDalali;
	}
	public String getTotalR() {
		return totalR;
	}
	public void setTotalR(String totalR) {
		this.totalR = totalR;
	}
	public String getTotalRebet() {
		return totalRebet;
	}
	public void setTotalRebet(String totalRebet) {
		this.totalRebet = totalRebet;
	}
	
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		String userrole = (String) ActionContext.getContext().getSession().get("userrole"); 
		if ((null != userrole) && ( userrole.equals("admin") || userrole.equals("superadmin"))) {
			
		}else
			return "unauthorised";
		
		AllDBFunction allDBFunction = new AllDBFunction();
		CommFunction commFunction = new CommFunction();
		int date = commFunction.formatDateForDb(datebusiness);
		allDBFunction.updateAnalysisReport(barcode, pono, brockername, commisionAgent, date, partyname, vehicle, address, noofbag, city, weight, comodity, sandActual, sandDiff, pricesand, moistureActual, moistureDiff, priceSubMoisture, rate, damageActual, damageDiff, pricesubdamage, gross, costunload, lessRebet, discount, addDalali, totalR, totalRebet,advance);
		allDBFunction.deleteAnalysisfromDB(barcode);
		addActionMessage("Analysis report submitted succesfully");
		return "success";
	}
}
